package com.yc.chaoshi.cs_user.mapper;

import com.yc.chaoshi.entity.PmsGoods;
import com.yc.chaoshi.entity.UmsUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xz
 * @since 2022-08-04
 */
public interface UmsUserMapper extends BaseMapper<UmsUser> {


    @Insert("insert into ums_user(phone,email,username,password) values(#{username},#{email},${username},#{password})")
    int insert(String username, String password,String email);

    @Select("select * from ums_user where id=#{id}")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "id",property = "goods",
                    many = @Many(select = "selectProductByCart"))
    })
    UmsUser selectWithId(int id);

    @Select("select * from  pms_goods a  join oms_cartitem b on a.id=b.product_id where b.user_id=#{id}")
    List<PmsGoods> selectProductByCart(int id);

}
